object Cubes {
	def main() : Unit = {
		if (
			new Cube().cube(1) == 1 &&
			new Cube().cube(2) == 8 &&
			new Cube().cube(3) == 27 &&
			new Cube().cube(4) == 64
		)
		println("PASS: cubes test");
		else println("FAIL: cubes test");
	}
}

/* simple sum */

class Sum {
	def add(a:Int, b:Int) : Int = { return a+b; } 
}

// dumb multiplication

class Mul extends Sum {
	def mul(a:Int, b:Int) : Int = { 
		var i:Int;
		var p:Int;
		i = 0;
		p = 0;
		while (i<a) {
			p = this.add(p,b);
			i = i+1;
		}
		return p;
	}
}

// here we are unsing the formerly defined functions

class Cube extends Mul {
	def cube(a:Int) : Int = {
		var r:Int;
		var i:Int;
		r = 0;
		i = 0;
		while (i<a) {
			r = r + this.mul(a, a);
			i = i + 1;
		}
		return r;
	}
}
